package com.qf;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsOrder;
import com.qf.service.OrderService;
import com.qf.util.ResponseUtil;
import com.qf.vo.CatVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 订单管理
 * @author 孙亚梅
 * @version V1.0
 * @Project javase2203
 * @Package com.qf.controller
 * @Description:
 * @Date 2022/6/26 17:24
 */
@RestController
@RequestMapping("/order")
@CrossOrigin("*")
public class OrderController {

    @Autowired
    private  OrderService orderService;


    @GetMapping("/list")
    public  Object OrderList(Integer userId,String orderSn,Integer orderStatus,
                             @RequestParam(defaultValue = "1") Integer page,
                             @RequestParam(defaultValue = "20") Integer limit,
                             @RequestParam(defaultValue = "add_time") String sort,
                             @RequestParam(defaultValue = "desc") String order){

        //调用service业务方法
        IPage<DtsOrder> resultPage = orderService.queryOrderPage(userId, orderSn, orderStatus, page, limit, sort, order);

        //获取查询的数据
        List<DtsOrder> list = resultPage.getRecords();
        //获取数据总页数
        long total = resultPage.getTotal();
        //封装数据并返回数据
        Map<String , Object> data = new HashMap<>();
        data.put("total",total);
        data.put("items",list);

        return ResponseUtil.ok(data);

    }

//    @GetMapping("/listShipChannel")
//    public  Object listShipChannel(){
//        List<DtsOrder>  shipChannel= orderService.findShipChannel();
//
//
//        //封装数据并返回数据
//        Map<String , Object> data = new HashMap<>();
//        data.put("shipChannel",shipChannel);
//
//
//        return ResponseUtil.ok(data);
//    }

}
